/*
 * @(#)XfuzzyEnumDataType.java        1.0 2009/03/25
 *
 * This file is part of Xfuzzy 3.0, a design environment for fuzzy logic
 * based systems.
 *
 * (c) 2000 IMSE-CNM. The authors may be contacted by the email address:
 *                    xfuzzy-team@imse.cnm.es
 *
 * Xfuzzy is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation.
 *
 * Xfuzzy is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

package xfuzzy.xfds;

import java.util.Vector;

import xfuzzy.lang.Universe;

/**
 * Clase que describe un tipo de dato enumerado
 * 
 * @author Francisco Jos� Moreno Velo
 *
 */
public class XfdsEnumDataType extends XfdsDataType  {

	//----------------------------------------------------------------------------//
	//                            MIEMBROS PRIVADOS                               //
	//----------------------------------------------------------------------------//

	/**
	 * Vector de valores enumerados
	 */
	private Vector<String> vector;
		
	//----------------------------------------------------------------------------//
	//                                CONSTRUCTOR                                 //
	//----------------------------------------------------------------------------//

	/**
	 * Constructor
	 */
	public XfdsEnumDataType() {
		this.vector = new Vector<String>();
	}
		
	//----------------------------------------------------------------------------//
	//                             M�TODOS P�BLICOS                               //
	//----------------------------------------------------------------------------//

	/**
	 * A�ade un valor a la enumeraci�n
	 */
	public void addValue(String value) {
		vector.add(value);
	}
	
	/**
	 * Obtiene la posici�n de un valor
	 */
	public int getIndex(String value) {
		return vector.indexOf(value);
	}

	/**
	 * Obtiene el valor asociado a la cadena reconocida
	 */
	public double getValue(String v){
		return (double) vector.indexOf(v);
	}

	/**
	 * Obtiene el n�mero de valores de la enumeraci�n
	 */
	public int getSize() {
		return this.vector.size();
	}
	
	/**
	 * Obtiene los diferentes valores de la enumeraci�n
	 */
	public String[] getValues() {
		String[] values = new String[vector.size()];
		vector.copyInto(values);
		return values;
	}

	/**
	 * Obtiene el valor del rango del tipo
	 */
	public double getRange() {
		return (double) (vector.size() - 1);
	}
	
	/**
	 * Obtiene el universo de discurso del atributo
	 * @return
	 */
	public Universe getUniverse() {
		try { 
			return new Universe(0,vector.size()-1);
		} catch(Exception ex) {
			return new Universe();
		}
	}

	/**
	 * Obtiene el marcador que indica si el rango ha sido asignado
	 * @return
	 */
	public boolean isRanged() {
		return true;
	}
	
	/**
	 * Asigna el valor m�ximo y m�nimo del rango del tipo de dato
	 * @param min
	 * @param max
	 */
	public void setRange(double min, double max) {
	}

	//----------------------------------------------------------------------------//
	//                             M�TODOS PRIVADOS                               //
	//----------------------------------------------------------------------------//


}
